#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<vector<int> > generateMatrix(int n)
{
    vector<vector<int> > matrix(n, vector<int>(n, 0));
    int i = 0, j = 0, z = 1;
    while (z <= n * n)
    {
        while (i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0)
        {
            matrix[i][j++] = z++;
        }
        i++;
        j--;
        while (i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0)
        {
            matrix[i++][j] = z++;
        }
        i--;
        j--;
        while (i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0)
        {
            matrix[i][j--] = z++;
        }
        i--;
        j++;
        while (i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0)
        {
            matrix[i--][j] = z++;
        }
        i++;
        j++;
    }
    return matrix;
}

int main()
{
    //TODO
    return 0;
}
